package com.coconet.gas.test;

import java.util.ArrayList;
import java.util.HashMap;
import java.util.List;
import java.util.Map;

public class demoTest03 {
    public static void main(String[] args) {
        UserDomain userDomain = new UserDomain("张三",1,"男","黑龙江");
        UserDomain userDomain2 = new UserDomain("李四",4,"男","吉林");
        UserDomain userDomain3 = new UserDomain("刘六",1,"男","辽宁");
        UserDomain userDomain4 = new UserDomain("王五",1,"男","新加坡");
        List<UserDomain> list = new ArrayList<>();
        list.add(userDomain);
        list.add(userDomain2);
        list.add(userDomain3);
        list.add(userDomain4);

        HashMap<String, UserDomain> usermap = new HashMap<>();

        List<UserDomain> list1 = new ArrayList<>();
        for (UserDomain domain : list) {
            usermap.put(domain.getAddress(),domain);
        }

        ArrayList<UserDomain> userDomains = new ArrayList<>();
        ArrayList<String> strings = new ArrayList<>();


        usermap.entrySet().stream().forEach(a ->{userDomains.add(a.getValue());strings.add(a.getKey());});




        for (UserDomain domain : userDomains) {
            System.out.println(domain);
        }
        for (String string : strings) {
            System.out.println(string);
        }



    }
}
